package com.caltco.cargo.ops.modules.sys.controller;

import com.caltco.cargo.ops.common.api.R2;
import com.caltco.cargo.ops.common.api.Result;
import com.caltco.cargo.ops.modules.sys.request.DailyTaskRequest;
import com.caltco.cargo.ops.modules.sys.request.DeleteDailyTaskRequest;
import com.caltco.cargo.ops.modules.sys.service.DailyTaskService;
import com.caltco.cargo.ops.modules.sys.vo.DailyTaskDayVO;
import com.caltco.cargo.ops.modules.sys.vo.DailyTaskVO;
import org.springframework.web.bind.annotation.*;

@RestController("dailyTaskController")
@RequestMapping("/api/daily_task")
public class DailyTaskController {

    private final DailyTaskService dailyTaskService;

    public DailyTaskController(DailyTaskService dailyTaskService) {
        this.dailyTaskService = dailyTaskService;
    }

    @GetMapping("getDailyTaskByDay")
    public Result<DailyTaskVO> getDailyTaskByDay() {
        return R2.ok(dailyTaskService.getDailyTaskByDay());
    }

    @GetMapping("getDailyTaskByMonth")
    public Result<DailyTaskDayVO> getDailyTaskByMonth() {
        return R2.ok(dailyTaskService.getDailyTaskByMonth());
    }

    @PostMapping("setDailyTaskByDay")
    public Result<String> setDailyTaskByDay(@RequestBody DailyTaskRequest request) {
        return dailyTaskService.setDailyTaskByDay(request) ? R2.ok("操作成功") : R2.err("操作失败");
    }

    @DeleteMapping("deleteDailyTask")
    private Result<String> deleteDailyTask(@RequestBody DeleteDailyTaskRequest request) {
        return dailyTaskService.deleteDailyTask(request) ? R2.ok("删除成功") : R2.err("删除失败");
    }
}
